﻿@{
    Layout = "~/Views/Shared/_LayoutFlat.cshtml";
}
@section scripts
{
    <script src="@Url.Content("~/Scripts/shared/share.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/shared/shown.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/common/gridlayout.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/common/export.js")" type="text/javascript"></script>
}
<body>
    <form id="form1" runat="server" method="post" style="height: 100%">

        @Html.Partial("~/Views/Modular/ReportsToolbar.cshtml")

        <div id="DivHeader">
            <table style="margin-bottom:4px;">
                <tr>
                    <td width="70px" align="right">统计日期：</td>
                    <td width="310px">
                        @Html.Partial("~/Views/Modular/dxDateRange.cshtml")
                    </td>
                    <td width="70px" align="right">分店名称：</td>
                    <td width="200px">
                        @Html.Partial("~/Views/Modular/LookupCorpInfo.cshtml")
                    </td>
                </tr>
            </table>
            <table>
                <tr>
                    <td width="5px" align="left"></td>
                    <td width="60px" align="left">客单均价：</td>
                    <td width="70px" align="center">
                        <a id="chk_Price0" checkOnClick="true" groupName="gPrice" class="mini-button" width="70px" plain="true" checked="true" oncheckedchanged="onCheckedChanged0" >不限</a>
                    </td>
                    <td width="70px" align="center">
                        <a id="chk_Price1" checkOnClick="true" groupName="gPrice" class="mini-button" width="70px" plain="true" oncheckedchanged="onCheckedChanged0" >< 10</a>
                    </td>
                    <td width="70px" align="center">
                        <a id="chk_Price2" checkOnClick="true" groupName="gPrice" class="mini-button" width="70px" plain="true" oncheckedchanged="onCheckedChanged0" >10-20</a>
                    </td>
                    <td width="70px" align="center">
                        <a id="chk_Price3" checkOnClick="true" groupName="gPrice" class="mini-button" width="70px" plain="true" oncheckedchanged="onCheckedChanged0" >20-30</a>
                    </td>
                    <td width="70px" align="center">
                        <a id="chk_Price4" checkOnClick="true" groupName="gPrice" class="mini-button" width="70px" plain="true" oncheckedchanged="onCheckedChanged0" >30-50</a>
                    </td>
                    <td width="70px" align="center">
                        <a id="chk_Price5" checkOnClick="true" groupName="gPrice" class="mini-button" width="70px" plain="true" oncheckedchanged="onCheckedChanged0" >50-100</a>
                    </td>
                    <td width="70px" align="center">
                        <a id="chk_Price6" checkOnClick="true" groupName="gPrice" class="mini-button" width="70px" plain="true" oncheckedchanged="onCheckedChanged0" >> 100</a>
                    </td>
                    <td width="70px" align="center">
                        <a id="chk_Price7" checkOnClick="true" groupName="gPrice" class="mini-button" width="70px" plain="true" oncheckedchanged="onCheckedChanged0" >自定义</a>
                    </td>
                    <td width="70px" align="center">
                        <input name="FPrice1" class="mini-spinner" minValue="0" maxValue="99999999" changeOnMousewheel="false" value="0"
                         style="width: 60px;" showbutton="false" align="center" selectOnFocus="true" />
                    </td>
                    <td width="5px" align="center">
                        ~
                    </td>
                    <td width="70px" align="center">
                        <input name="FPrice2" class="mini-spinner" minValue="0" maxValue="99999999" changeOnMousewheel="false" value="0"
                         style="width: 60px;" showbutton="false" align="center" selectOnFocus="true" />
                    </td>
                </tr>
                <tr>
                    <td width="5px" align="left"></td>
                    <td width="60px" align="left">消费次数：</td>
                    <td width="70px" align="center">
                        <a id="chk_PosCount0" checkOnClick="true" groupName="gPosCount" class="mini-button" width="70px" plain="true" checked="true" oncheckedchanged="onCheckedChanged1" >不限</a>
                    </td>
                    <td width="70px" align="center">
                        <a id="chk_PosCount1" checkOnClick="true" groupName="gPosCount" class="mini-button" width="70px" plain="true" oncheckedchanged="onCheckedChanged1" ><=2</a>
                    </td>
                    <td width="70px" align="center">
                        <a id="chk_PosCount2" checkOnClick="true" groupName="gPosCount" class="mini-button" width="70px" plain="true" oncheckedchanged="onCheckedChanged1" >2-5</a>
                    </td>
                    <td width="70px" align="center">
                        <a id="chk_PosCount3" checkOnClick="true" groupName="gPosCount" class="mini-button" width="70px" plain="true" oncheckedchanged="onCheckedChanged1" >5-10</a>
                    </td>
                    <td width="70px" align="center">
                        <a id="chk_PosCount4" checkOnClick="true" groupName="gPosCount" class="mini-button" width="70px" plain="true" oncheckedchanged="onCheckedChanged1" >10-15</a>
                    </td>
                    <td width="70px" align="center">
                        <a id="chk_PosCount5" checkOnClick="true" groupName="gPosCount" class="mini-button" width="70px" plain="true" oncheckedchanged="onCheckedChanged1" >15-20</a>
                    </td>
                    <td width="70px" align="center">
                        <a id="chk_PosCount6" checkOnClick="true" groupName="gPosCount" class="mini-button" width="70px" plain="true" oncheckedchanged="onCheckedChanged1" >>=20</a>
                    </td>
                    <td width="70px" align="center">
                        <a id="chk_PosCount7" checkOnClick="true" groupName="gPosCount" class="mini-button" width="70px" plain="true" oncheckedchanged="onCheckedChanged1" >自定义</a>
                    </td>
                    <td width="70px" align="center">
                        <input name="FPosCount1" class="mini-spinner" minValue="0" maxValue="99999999" changeOnMousewheel="false" value="0"
                         style="width: 60px;" showbutton="false" align="center" selectOnFocus="true" />
                    </td>
                    <td width="5px" align="center">
                        ~
                    </td>
                    <td width="70px" align="center">
                        <input name="FPosCount2" class="mini-spinner" minValue="0" maxValue="99999999" changeOnMousewheel="false" value="0"
                         style="width: 60px;" showbutton="false" align="center" selectOnFocus="true" />
                    </td>
                </tr>
                <tr>
                    <td width="5px" align="left"></td>
                    <td width="60px" align="left">累计充值：</td>
                    <td width="70px" align="center">
                        <a id="chk_DepAmount0" checkOnClick="true" groupName="gDepAmount" class="mini-button" width="70px" plain="true" checked="true" oncheckedchanged="onCheckedChanged2" >不限</a>
                    </td>
                    <td width="70px" align="center">
                        <a id="chk_DepAmount1" checkOnClick="true" groupName="gDepAmount" class="mini-button" width="70px" plain="true" oncheckedchanged="onCheckedChanged2" ><=10</a>
                    </td>
                    <td width="70px" align="center">
                        <a id="chk_DepAmount2" checkOnClick="true" groupName="gDepAmount" class="mini-button" width="70px" plain="true" oncheckedchanged="onCheckedChanged2" >10-100</a>
                    </td>
                    <td width="70px" align="center">
                        <a id="chk_DepAmount3" checkOnClick="true" groupName="gDepAmount" class="mini-button" width="70px" plain="true" oncheckedchanged="onCheckedChanged2" >100-500</a>
                    </td>
                    <td width="70px" align="center">
                        <a id="chk_DepAmount4" checkOnClick="true" groupName="gDepAmount" class="mini-button" width="70px" plain="true" oncheckedchanged="onCheckedChanged2" >500-1000</a>
                    </td>
                    <td width="70px" align="center">
                        <a id="chk_DepAmount5" checkOnClick="true" groupName="gDepAmount" class="mini-button" width="70px" plain="true" oncheckedchanged="onCheckedChanged2" >1000-2000</a>
                    </td>
                    <td width="70px" align="center">
                        <a id="chk_DepAmount6" checkOnClick="true" groupName="gDepAmount" class="mini-button" width="70px" plain="true" oncheckedchanged="onCheckedChanged2" >>=2000</a>
                    </td>
                    <td width="70px" align="center">
                        <a id="chk_DepAmount7" checkOnClick="true" groupName="gDepAmount" class="mini-button" width="70px" plain="true" oncheckedchanged="onCheckedChanged2" >自定义</a>
                    </td>
                    <td width="70px" align="center">
                        <input name="FDepAmount1" class="mini-spinner" minValue="0" maxValue="99999999" changeOnMousewheel="false" value="0"
                         style="width: 60px;" showbutton="false" align="center" selectOnFocus="true" />
                    </td>
                    <td width="5px" align="center">
                        ~
                    </td>
                    <td width="70px" align="center">
                        <input name="FDepAmount2" class="mini-spinner" minValue="0" maxValue="99999999" changeOnMousewheel="false" value="0"
                         style="width: 60px;" showbutton="false" align="center" selectOnFocus="true" />
                    </td>
                </tr>
                <tr>
                    <td width="5px" align="left"></td>
                    <td width="60px" align="left">累计积分：</td>
                    <td width="70px" align="center">
                        <a id="chk_DepPoint0" checkOnClick="true" groupName="gDepPoint" class="mini-button" width="70px" plain="true" checked="true" oncheckedchanged="onCheckedChanged3" >不限</a>
                    </td>
                    <td width="70px" align="center">
                        <a id="chk_DepPoint1" checkOnClick="true" groupName="gDepPoint" class="mini-button" width="70px" plain="true" oncheckedchanged="onCheckedChanged3" ><=10</a>
                    </td>
                    <td width="70px" align="center">
                        <a id="chk_DepPoint2" checkOnClick="true" groupName="gDepPoint" class="mini-button" width="70px" plain="true" oncheckedchanged="onCheckedChanged3" >10-100</a>
                    </td>
                    <td width="70px" align="center">
                        <a id="chk_DepPoint3" checkOnClick="true" groupName="gDepPoint" class="mini-button" width="70px" plain="true" oncheckedchanged="onCheckedChanged3" >100-500</a>
                    </td>
                    <td width="70px" align="center">
                        <a id="chk_DepPoint4" checkOnClick="true" groupName="gDepPoint" class="mini-button" width="70px" plain="true" oncheckedchanged="onCheckedChanged3" >500-1000</a>
                    </td>
                    <td width="70px" align="center">
                        <a id="chk_DepPoint5" checkOnClick="true" groupName="gDepPoint" class="mini-button" width="70px" plain="true" oncheckedchanged="onCheckedChanged3" >1000-5000</a>
                    </td>
                    <td width="70px" align="center">
                        <a id="chk_DepPoint6" checkOnClick="true" groupName="gDepPoint" class="mini-button" width="70px" plain="true" oncheckedchanged="onCheckedChanged3" >>=5000</a>
                    </td>
                    <td width="70px" align="center">
                        <a id="chk_DepPoint7" checkOnClick="true" groupName="gDepPoint" class="mini-button" width="70px" plain="true" oncheckedchanged="onCheckedChanged3" >自定义</a>
                    </td>
                    <td width="70px" align="center">
                        <input name="FDepPoint1" class="mini-spinner" minValue="0" maxValue="99999999" changeOnMousewheel="false" value="0"
                         style="width: 60px;" showbutton="false" align="center" selectOnFocus="true" />
                    </td>
                    <td width="5px" align="center">
                        ~
                    </td>
                    <td width="70px" align="center">
                        <input name="FDepPoint2" class="mini-spinner" minValue="0" maxValue="99999999" changeOnMousewheel="false" value="0"
                         style="width: 60px;" showbutton="false" align="center" selectOnFocus="true" />
                    </td>
                </tr>
            </table>
        </div>
        <div class="mini-fit">
            <div id="datagrid1" class="mini-datagrid" style="width:100%;height:100%;" borderStyle="border:1;" pageSize="15"
                 url="../Member/GetSpendingPower"
                 allowCellSelect="true" allowCellEdit="true" showSummaryRow="false" fitColumns="false">
                <div property="columns">
                    <div type="checkcolumn"></div>
                    <div field="FNumber" name="FNumber" width="100" headerAlign="center">会员卡号</div>
                    <div field="FName" name="FName" width="130" headerAlign="center">会员姓名</div>
                    <div field="FPhone" name="FPhone" width="110" headerAlign="center">手机号</div>
                    <div field="FPoint" name="FPoint" width="80" headerAlign="center" align="right" numberFormat="#">当前积分</div>
                    <div field="FAmount" name="FAmount" width="90" headerAlign="center" align="right" numberFormat="#,0.00">当前余额</div>
                    <div field="FPointSum" name="FPointSum" width="80" headerAlign="center" align="right" numberFormat="#">累计积分</div>
                    <div field="FAmountSum" name="FAmountSum" width="100" headerAlign="center" align="right" numberFormat="#,0.00">累计充值</div>
                    <div field="FPosCount" name="FPosCount" width="80" headerAlign="center" align="right" numberFormat="#">消费次数</div>
                    <div field="FAvgPrice" name="FAvgPrice" width="100" headerAlign="center" align="right" numberFormat="#,0.00">客单均价</div>
                    <div field="FConsumeTime" name="FConsumeTime" width="130" headerAlign="center" dateFormat="yyyy-MM-dd hh:mm:ss">最近消费日期</div>
                    <div field="FClassName" name="FClassName" width="100" headerAlign="center">会员分类</div>
                    <div field="FStockName" name="FStockName" width="120" headerAlign="center">开卡门店</div>                 
                </div>
            </div>
        </div>

    <div>
        <table>
            <tr>
                <td width ="40px" align="right">说明：</td>
                <td align="left">
                    会员占比=会员数/会员数合计；消费会员占比=消费会员数/消费会员数合计；消费会员比率=消费会员数/会员数；消费金额占比=消费金额/消费金额合计
                </td>
            </tr>
        </table>
    </div>

        <script type="text/javascript">

        mini.parse();
        var form = new mini.Form("form1");
        var grid = mini.get("datagrid1");
        var uID = parent.window.getSystemAppID();
        var sumFields = "";
        var mFPrice0 = "chk_Price0";
        var mFPosCount0 = "chk_PosCount0";
        var mFDepAmount0 = "chk_DepAmount0";
        var mFDepPoint0 = "chk_DepPoint0";

        function FormShown() {
            var nowDate = new Date();
            mini.getbyName("FDate1").setValue(nowDate);
            mini.getbyName("FDate2").setValue(nowDate);
            LoadData();
        }

        function onCheckedChanged0(e) {
            var chk = e.sender;
            var checked = chk.getChecked();
            var text = chk.getText();
            var mid = $(this).attr("id");
            if (checked) {
                mFPrice0 = mid;
            }
        }

        function onCheckedChanged1(e) {
            var chk = e.sender;
            var checked = chk.getChecked();
            var text = chk.getText();
            var mid = $(this).attr("id");
            if (checked) {
                mFPosCount0 = mid;
            }
        }

        function onCheckedChanged2(e) {
            var chk = e.sender;
            var checked = chk.getChecked();
            var text = chk.getText();
            var mid = $(this).attr("id");
            if (checked) {
               mFDepAmount0 = mid;
            }
        }

        function onCheckedChanged3(e) {
            var chk = e.sender;
            var checked = chk.getChecked();
            var text = chk.getText();
            var mid = $(this).attr("id");
            if (checked) {
                mFDepPoint0 = mid;
            }
        }

        function clearloca() {
            getPriceJson();
            mini.getbyName("FCorpItemID").setValue("");
            mini.getbyName("FCorpItemID").setText("");
            mini.getbyName("FCorpName").setValue("");
            var nowDate = new Date();
            mini.getbyName("FDate1").setValue(nowDate);
            mini.getbyName("FDate2").setValue(nowDate);
            mini.getbyName("comdatasel").setValue(0);
        }

        function getPriceJson() {
            var mjson = "";
            var mvar = mini.get("chk_Price0").getValue();
            alert(mvar);
        }

        function LoadData() {
            var cDate1 = mini.getbyName("FDate1").getFormValue();
            var cDate2 = mini.getbyName("FDate2").getFormValue();
            var mFCorpID = mini.getbyName("FCorpItemID").getValue();
            var mFPrice1 = mini.getbyName("FPrice1").getValue();
            var mFPrice2 = mini.getbyName("FPrice2").getValue();
            var mFPosCount1 = mini.getbyName("FPosCount1").getValue();
            var mFPosCount2 = mini.getbyName("FPosCount2").getValue();
            var mFDepAmount1 = mini.getbyName("FDepAmount1").getValue();
            var mFDepAmount2 = mini.getbyName("FDepAmount2").getValue();
            var mFDepPoint1 = mini.getbyName("FDepPoint1").getValue();
            var mFDepPoint2 = mini.getbyName("FDepPoint2").getValue();

            var json = "[{";
            json = json + '"mReportType":' + '"6001",';//列表类型
            json = json + '"mSystemAppID":' + '"' + uID + '",';
            json = json + '"mDate1":' + '"' + cDate1 + '",';            
            json = json + '"mDate2":' + '"' + cDate2 + '",';
            json = json + '"mFPrice0":"' + mFPrice0 + '",';
            json = json + '"mFPrice1":"' + mFPrice1 + '",';
            json = json + '"mFPrice2":"' + mFPrice2 + '",';
            json = json + '"mFPosCount0":"' + mFPosCount0 + '",';
            json = json + '"mFPosCount1":"' + mFPosCount1 + '",';
            json = json + '"mFPosCount2":"' + mFPosCount2 + '",';
            json = json + '"mFDepAmount0":"' + mFDepAmount0 + '",';
            json = json + '"mFDepAmount1":"' + mFDepAmount1 + '",';
            json = json + '"mFDepAmount2":"' + mFDepAmount2 + '",';
            json = json + '"mFDepPoint0":"' + mFDepPoint0 + '",';
            json = json + '"mFDepPoint1":"' + mFDepPoint1 + '",';
            json = json + '"mFDepPoint2":"' + mFDepPoint2 + '",';
            json = json + '"mFCorpID":' + '"' + mFCorpID + '"';
            json = json + "}]";

            grid.load({ mydata: json });

            mExportDataUrl = grid.url;
            mExportDataJson = json;//导出
        }

        function printdata() {
            var url = "../Report/PrintReport";
            mini.open({
                url: url,
                title: "打印", width: 1000, height: 700,
                onload: function () {
                    var iframe = this.getIFrameEl();
                    var NoneDisplayCol = [0];
                    iframe.contentWindow.InitalPrint(grid, NoneDisplayCol, parent.window.getSystemCompany() + "会员消费排行表");
                }
            });
        }

        </script>
    </form>
</body>